<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\api\validate\user;

use crmeb\exceptions\ApiException;
use think\Validate;

/**
 * 用户地址验证类
 * Class AddressValidate
 * @package app\http\validates\user
 */
class UpdUserValidate extends Validate
{

    protected $rule = [
        'nickname' => 'max:25',
        'mail' => 'email',
        'phone' =>  'mobile',
        'gender'    =>  'in:1,2',
        'avatar'    =>  'url',
        'password' => 'requireCallback:check_password|length:6,32',
        'password_confirm' => 'requireWith:password|confirm:password',
    ];

    protected $message = [
        'nickname.max' => '昵称不能超过25个字符',
        'mail' => '邮箱格式错误',
        'phone' => '手机号格式错误',
        'gender.in' => '性别只能是1或2',
        'avatar.url' => '头像必须是有效的URL地址',
        'password.length' => '密码长度不能小于6，大于32',
        'password_confirm.requireWith' => '确认密码不能为空',
        'password_confirm.confirm' => '两次输入密码不一致'
    ];

    function check_password($value, $data)
    {
        if (empty($value)) return false;
    }
}
